#ifndef _PARTICLE_SYSTEM_H
#define _PARTICLE_SYSTEM_H

#include "Particle.h"
#include "Constraint.h"
#include "Object.h"
#include "CollisionSystem.h"

#include <set>
using namespace std;

class Object; // forward declaration
class CollisionSystem; // forward declaration

class ParticleSystem {
public:
	double timeStep;
	double dampingAir;
	Vector3 gravitationalAcceleration;
	// Number of relaxations to solve the constraints
	int numIterations;
	// A set of objects. Objects keep their internal constraints
	set<Object*> object;
	// A set of additional constraints
	set<Constraint*> constraint;
	CollisionSystem* collisionSystem;

	ParticleSystem();
	void update();
	void addObject(Object* o);
	void removeObject(Object* o);
private:
	void verlet();
	void satisfyConstraints();
	void accumulateForces();
};

#endif /* _PARTICLE_SYSTEM_H */
